﻿using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

namespace Devonline.Identity
{
    /// <summary>
    /// Store 接口
    /// </summary>
    /// <typeparam name="TGroup"></typeparam>
    /// <typeparam name="TKey"></typeparam>
    public interface IGroupStore<TGroup, TKey> : IIdentityStore<TGroup, TKey> where TGroup : Group<TKey> where TKey : IEquatable<TKey>, IConvertible
    {
        /// <summary>
        /// Finds and returns parent Group, if any, who has the specified <paramref name="id"/>.
        /// </summary>
        /// <param name="id">The Group id to search for.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
        /// <returns>
        /// The <see cref="Task"/> that represents the asynchronous operation, containing the resource matching the specified <paramref name="resourceId"/> if it exists.
        /// </returns>
        Task<TGroup> GetParentGroupAsync(TKey id, CancellationToken cancellationToken = default);

        /// <summary>
        /// Finds and returns children Group, if any, who has the specified <paramref name="id"/>.
        /// </summary>
        /// <param name="id">The Group id to search for.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
        /// <returns>
        /// The <see cref="Task"/> that represents the asynchronous operation, containing the resource matching the specified <paramref name="resourceId"/> if it exists.
        /// </returns>
        Task<IList<TGroup>> GetChildrenGroupsAsync(TKey id, CancellationToken cancellationToken = default);
    }
}
